1. Technology Field
The present invention relates to a block management method and particularly to a block management method for managing physical blocks of a rewritable non-volatile memory module, and a memory controller and a memory storage apparatus using the same.
2. Description of Related Art
Along with the widespread of digital cameras, cell phones, and MP3 in recently years, the consumers' demand to storage media has increased drastically. Rewritable non-volatile memory is one of the most adaptable memories for electric products (e.g. notebooks) due to its characteristics such as data non-volatility, low power consumption, small volume, non-mechanical structure and high access speed. A solid state drive (SSD) is a storage apparatus adopting NAND flash memory as storage medium. Therefore, the flash memory industry has become a very important part of the electronic industry in recent years.
A rewritable non-volatile memory module has a plurality of physical blocks, and each physical block has a plurality of physical pages, wherein data must be written orderly into a physical block according to the sequence of the physical pages in the physical block. Additionally, a physical page, which has stored data thereon, has to be erased before the physical page is used for writing with data again. In particular, a smallest unit for erasing data is one physical block, and a smallest unit for programming (also referred to writing) data is one physical page.
Therefore, when a rewritable non-volatile memory storage apparatus (hereinafter referred to as the memory storage apparatus) is manufactured and pre-formatted (i.e., a pre-formatting operation), the memory controller of the memory storage apparatus performs a scan disk operation on all physical blocks of the rewritable non-volatile memory module to identify good physical blocks, selecting enough physical blocks for a data area and a spare area from the good physical blocks and groups other good physical blocks into a replacement area. Herein, the pre-formatting operation includes initial steps needed to be perform on the rewritable non-volatile memory storage apparatus before the rewritable non-volatile memory storage apparatus is formatted.
The physical blocks of the data area are used for storing data written by the host system and the physical blocks of the spare area is used for substituting the physical blocks of the data area. Accordingly, the physical blocks of the spare area are either blank or available blocks (i.e., no data is recorded in these blocks or data recorded in these blocks is marked as invalid data). That is, the physical pages of the physical blocks of the data area and the spare area are used alternately for mapping to the logical pages of the logical blocks to store data written by the host system. For example, when the host system is about to store data on a logical page of a logical block in the memory storage apparatus, the memory controller selects a physical block as a substitution block, writes the data into a physical page of the substitution physical block and records a mapping for indicating that the data of this logical page is stored on this physical page. Additionally, a physical page originally mapping to the logical page in the data area is marked as invalid.
The physical blocks of the replacement area are used for replacing bad physical blocks occurred during the operation of memory storage apparatus. In details, after an erasing count of a physical block exceeds a threshold (e.g., 10000), the physical block may become a bad physical block that can not be programmed anymore. Therefore, when a physical block in the data area becomes a bad physical block, the memory controller tries to get an available physical block from the replacement area for replacing the bad physical block. In particular, if there is no more available physical block in the replacement area, the memory storage apparatus is announced as being in a write-protect status and cannot be used for writing data anymore.
However, in fact, when there is no more available physical block in the replacement area for replacing the bad physical blocks, there are still many good physical blocks in the data area and the spare area. Therefore, if these good physical blocks can continue to be used for storing data, the lifespan of the memory storage apparatus may be prolonged.
Nothing herein should be construed as an admission of knowledge in the prior art of any portion of the present invention. Furthermore, citation or identification of any document in this application is not an admission that such document is available as prior art to the present invention, or that any reference forms a part of the common general knowledge in the art.